Testing NLTK and Stanford NER Taggers for Speed

by: D. Refaeli, 8 years ago


2 notes on this tutorial:

1) You don't actually need to pass any argument to process_text function, since it opens the text file anyway. So that should be changed to: def process_text() and make sure you don't pass it when you call the function:

def stanford_main():
print(stanford_tagger(process_text(txt_file))) - delete the txt_file

def nltk_main():
print(nltk_tagger(process_text(txt_file))) - delete the txt_file

2) os.times()[4] doesn't seem to work for me (Python 3.4) - if you're having the same problem, import time and use time.clock() instead:

import time

    stanford_t0 = time.clock()
    stanford_main()
    stanford_t1 = time.clock()
    stanford_total_time = (stanford_t1 - stanford_t0)

    nltk_t0 = time.clock()
    nltk_main()
    nltk_t1 = time.clock()
    nltk_total_time = (nltk_t1 - nltk_t0)



You must be logged in to post. Please login or register an account.



Thanks for sharing these notes!

-Harrison 8 years ago

You must be logged in to post. Please login or register an account.